
local MainScene = class("MainScene", cc.load("mvc").ViewBase)

local function AnchorPoint1(self)
    local red = cc.LayerColor:create(cc.c4b(255, 100, 100, 128))
    red:setContentSize(display.width / 2, display.height / 2)

    local green = cc.LayerColor:create(cc.c4b(100, 255, 100, 128))
    green:setContentSize(display.width / 4, display.height / 4)

    red:addChild(green)
    self:addChild(red)
end

local function AnchorPoint2(self)
    local red = cc.LayerColor:create(cc.c4b(255, 100, 100, 128))
    red:setContentSize(display.width / 2, display.height / 2)
    red:ignoreAnchorPointForPosition(false)
    red:setAnchorPoint(0.5, 0.5)
    red:setPosition(display.width / 2, display.height / 2)

    local green = cc.LayerColor:create(cc.c4b(100, 255, 100, 128))
    green:setContentSize(display.width / 4, display.height / 4)
    green:ignoreAnchorPointForPosition(false)
    green:setAnchorPoint(1, 1)

    red:addChild(green)
    self:addChild(red)
end

local function AnchorPoint3(self)
    local red = cc.LayerColor:create(cc.c4b(255, 100, 100, 128))
    red:setContentSize(display.width / 2, display.height / 2)
    -- red:ignoreAnchorPointForPosition(false)
    red:setAnchorPoint(0.5, 0.5)
    red:setPosition(display.width / 2, display.height / 2)

    local green = cc.LayerColor:create(cc.c4b(100, 255, 100, 128))
    green:setContentSize(display.width / 4, display.height / 4)
    -- green:ignoreAnchorPointForPosition(false)
    green:setAnchorPoint(1, 1)

    red:addChild(green)
    self:addChild(red)
end

function MainScene:onCreate()
    -- choose one func then note the other
    -- AnchorPoint1(self)
    -- AnchorPoint2(self)
    AnchorPoint3(self)
end

return MainScene
